package Buttons
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author Lokiraze
	 */
	public class Hint extends Buttons
	{
		public var game:Game;
		public function Hint(g:Game)
		{
			game = g;
			this.Draw();
			
			addEventListener(MouseEvent.CLICK, Hinted);
		}
		
		public function Draw()
		{
			txtButton.selectable = false;
			txtButton.text = "Hint";
		}
		
		public function Hinted(e:MouseEvent)
		{
			var index:int;
			var done:Boolean = false;
			
			while (!done)
			{
				index = Random(0, 80);
				if (!game.gridCells[index].isRevealed())
				{
					game.gridCells[index].ShowAnswer("Hint");
					return;
				}
			}
		}
		
		public function Random(min:int, max:int):int
		{
			var number:int = min - 1;

			while(number < min || number > max)
			{
					number = min + Math.round(Math.random() * (max - min));
			}

			return number;
		}
		
	}
	
}